(function (line) {
    line.extend(line, {
        //TODO: formatDate
        parseDate:function (date, format) {
            //TODO: i18n
            var week = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', '日', '一', '二', '三', '四', '五', '六'];
            return format.replace(/yyyy|yy|mm|dd|hh|min|ss|week|cnweek/g, function (d) {
                switch (d) {
                    case 'yyyy':
                    case 'yy':
                        return date.getFullYear().toString().slice(4 - d.length);
                    case 'mm':
                        return date.getMonth();
                    case 'dd':
                        return date.getDate();
                    case 'hh':
                        return date.getHours();
                    case 'min':
                        return line.padLeft(date.getMinutes().toString(), 2, '0');
                    case 'ss':
                        return line.padLeft(date.getSeconds().toString(), 2, '0');
                    case 'week':
                        return week[date.getDay()];
                    case 'cnweek':
                        return week[date.getDay() + 7];
                }
            });
        },
        parseDate2:function (date, format) {
            var week = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', '日', '一', '二', '三', '四', '五', '六'];
            var selector = ['yyyy', 'yy', 'mm', 'dd', 'hh', 'min', 'ss', 'week', 'cnweek'];
            return format.replace(new RegExp(selector.join('|'), 'g'), function (d) {
                switch (d) {
                    case selector[0]:
                    case selector[1]:
                        return date.getFullYear().toString().slice(4 - d.length);
                    case selector[2]:
                        return date.getMonth();
                    case selector[3]:
                        return date.getDate();
                    case selector[4]:
                        return date.getHours();
                    case selector[5]:
                        return line.padLeft(date.getMinutes().toString(), 2);
                    case selector[6]:
                        return line.padLeft(date.getSeconds().toString(), 2);
                    case selector[7]:
                        return week[date.getDay()];
                    case selector[8]:
                        return week[date.getDay() + 7];
                }
            });
        },
        parseDate3:function (date, format) {
            var week = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', '日', '一', '二', '三', '四', '五', '六'];
            var selector = {
                'yyyy':date.getFullYear(),
                'yy':date.getFullYear().toString().slice(2),
                'mm':date.getMonth(),
                'dd':date.getDate(),
                'hh':date.getHours(),
                'min':line.padLeft(date.getMinutes().toString(), 2),
                'ss':line.padLeft(date.getSeconds().toString(), 2),
                'week':week[date.getDay()],
                'cnweek':week[date.getDay() + 7]
            };
            return format.replace(new RegExp(line.keys(selector).join('|'), 'g'), function (key) {
                return selector[key];
            });
        }
    });
})(line);